<template>
  <el-form :inline="true"
           ref="strategyForm"
           :rules="strategyRule"
           label-width="150px"
           :model="form" class="demo-form-inline">
    <el-row>
      <el-col :span="8">
        <el-form-item label="单日提现金额" prop="dailyAmount">
          <el-input placeholder="请输入金额" v-model.number="form.dailyAmount">
            <template slot="prepend">></template>
            <template slot="append">元</template>
          </el-input>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="单次提现金额" prop="amount">
          <el-input placeholder="请输入金额" v-model.number="form.amount">
            <template slot="prepend">></template>
            <template slot="append">元</template>
          </el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8">
        <el-form-item label="单日提现次数" prop="dailyTimes">
          <el-input placeholder="请输入次数" v-model.number="form.dailyTimes">
            <template slot="prepend">></template>
            <template slot="append">次</template>
          </el-input>
        </el-form-item>
      </el-col>
      <!--<el-col :span="8">-->
        <!--<el-form-item label="连续提现次数" prop="continuousWithdrawTimes">-->
          <!--<el-input placeholder="请输入次数" v-model.number="form.continuousWithdrawTimes">-->
            <!--<template slot="prepend">>=</template>-->
            <!--<template slot="append">次</template>-->
          <!--</el-input>-->
        <!--</el-form-item>-->
      <!--</el-col>-->
      <!--<el-col :span="8">-->
        <!--<el-form-item label="连续提现时间配置" prop="continuousMinutes">-->
          <!--<el-input placeholder="请输入分钟" v-model.number="form.continuousMinutes">-->
            <!--<template slot="append">分钟</template>-->
          <!--</el-input>-->
        <!--</el-form-item>-->
      <!--</el-col>-->
    </el-row>
    <el-row>
      <el-col :span="8">
        <el-form-item label="首次提现金额" prop="firstAmount">
          <el-input placeholder="请输入金额" v-model.number="form.firstAmount">
            <template slot="prepend">></template>
            <template slot="append">元</template>
          </el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8">
        <el-form-item label="当日盈利金额" prop="dailyProfit">
          <el-input placeholder="请输入金额" v-model.number="form.dailyProfit">
            <template slot="prepend">></template>
            <template slot="append">元</template>
          </el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <!--<el-row>-->
      <!--<el-col :span="8">-->
        <!--<el-form-item label="7天累计提现金额" prop="totalWithdraw">-->
          <!--<el-input placeholder="请输入金额" v-model.number="form.totalWithdraw">-->
            <!--<template slot="prepend">>=</template>-->
            <!--<template slot="append">元</template>-->
          <!--</el-input>-->
        <!--</el-form-item>-->
      <!--</el-col>-->
    <!--</el-row>-->
    <el-row>
      <el-col :span="8">
        <el-form-item label="同IP多账号检测" prop="sameIPCheck">
          <el-radio-group v-model="form.sameIPCheck" size="medium">
            <el-radio-button :label="1" value="1">开启</el-radio-button>
            <el-radio-button :label="0" value="0">关闭</el-radio-button>
          </el-radio-group>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="同设备多账号检测" prop="sameDeviceCheck">
          <el-radio-group v-model="form.sameDeviceCheck" size="medium">
            <el-radio-button :label="1" value="1">开启</el-radio-button>
            <el-radio-button :label="0" value="0">关闭</el-radio-button>
          </el-radio-group>
        </el-form-item>
      </el-col>
    </el-row>
    <div style="padding: 0 0 0 150px">
      <el-button class="filter-item" type="primary" icon="el-icon-printer"
                 @click="doSave({action: 'saveForm', form: 'strategyForm'})">生成策略
      </el-button>
      <el-button @click="resetForm('strategyForm')">取消</el-button>
    </div>
  </el-form>
</template>

<script>
  import {form, factory} from '@/build'
  import {updateStrategyConfigs,getStrategyConfigs} from '@/services/api/strategy'

  export default {
    name: "strategy-form",
    mixins: [form, factory],
    data() {
      return {
        form: {
          dailyAmount: undefined,
          amount: undefined,
          dailyTimes: undefined,
          firstAmount: undefined,
          dailyProfit: undefined,
          sameIPCheck: undefined,
          sameDeviceCheck: undefined,
        },
        strategyRule: {
          dailyAmount: factory.getRule('money'),
          firstAmount: factory.getRule('money'),
          amount: factory.getRule('money'),
          dailyProfit: factory.getRule('money'),
          totalWithdraw: factory.getRule('money'),
          dailyTimes: [
            {required: true, message: '单日提现次数不能为空'},
            {validator: factory.getValidator('nonNegativeInteger')}
          ],
          sameIPCheck: [
            {required: true, message: '同IP多账号检测为必选项', trigger: 'change'}
          ],
          sameDeviceCheck: [
            {required: true, message: '同设备多账号检测为必选项', trigger: 'change'}
          ]
        }
      }
    },
    mounted() {
      this.bindSave(updateStrategyConfigs, 'saveForm', 'form', {
      });

      this.bindGet(getStrategyConfigs,'form',{
        format: data=>{
          this.loading = false;
          return data?data:{}
        }
      });
      this.getAll();
    },
  }
</script>

<style scoped>

</style>
